/*
 * Copyright DimYLiK.
 */

package com.example.myapp.utilities;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class ListDirectoryFiles {

    public static void main(String... args) {
        ListDirectoryFiles listDirectoryFiles = new ListDirectoryFiles();
        List<String> files = new ArrayList<String>();
        listDirectoryFiles.listCurrentDirectory(files);
        for (String file : files) {
            System.out.println(file);
        }
    }

    private void listCurrentDirectory(List<String> possibleWords) {
        try {
            File file = new File("");
            possibleWords.add(file.getAbsolutePath());

            listFiles(possibleWords, file, "");
        } catch (Exception e) {
            possibleWords.add(e.getMessage());
        }
    }

    private void listFiles(List<String> possibleWords, File file, String separator) {
        possibleWords.add(separator + file.getAbsolutePath());
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            for (File dirFile : files) {
                listFiles(possibleWords, dirFile, separator + "__");
            }
        }
    }
}
